'''
Created on Aug 19, 2009

@author: echeek
'''
import math

def pentagonal(n):
    return n*(3*n-1)/2;

def isPentagonal(p):
    n=(1+math.sqrt(1+24*p))/6;
    return n==math.floor(n);



def Euler44():
    n=1;
    pents=[];
    solved=False;
    while not solved:
        cur=pentagonal(n);
        for x in pents:
            if( isPentagonal(cur+x) and isPentagonal(cur-x) ):
                print cur-x;
                solved=True;
                break;
        pents.append(cur);
        n+=1;
        
Euler44();